//
//  TranscriptionEvent.swift
//  SpeechAnalyzerDemo
//
//  转写流程统一的数据模型，兼容新旧 Speech API。
//

import Foundation

struct TranscriptionEvent {
    let text: AttributedString
    let isFinal: Bool
    let confidence: Double?
    let isCompleteSentence: Bool  // 标识是否为完整句子（用于弹幕展示）

    init(text: AttributedString, isFinal: Bool, confidence: Double?, isCompleteSentence: Bool = false) {
        self.text = text
        self.isFinal = isFinal
        self.confidence = confidence
        self.isCompleteSentence = isCompleteSentence
    }
}

// MARK: - 弹幕消息模型
struct TranscriptionMessage: Identifiable {
    let id = UUID()
    let text: String
    let confidence: Double?
    let timestamp: Date

    init(text: String, confidence: Double? = nil) {
        self.text = text
        self.confidence = confidence
        self.timestamp = Date()
    }
}
